home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 10618 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.3 KB

  1. Path: mail2news.demon.co.uk!genesis.demon.co.uk
  2. From: Lawrence Kirby <fred@genesis.demon.co.uk>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Why doesn't this compile?
  5. Date: Mon, 18 Mar 96 22:04:33 GMT
  6. Organization: none
  7. Message-ID: <827186673snz@genesis.demon.co.uk>
  8. References: <4igck9$idj@masala.cc.uh.edu>
  9. Reply-To: fred@genesis.demon.co.uk
  10. X-NNTP-Posting-Host: genesis.demon.co.uk
  11. X-Newsreader: Demon Internet Simple News v1.27
  12. X-Mail2News-Path: genesis.demon.co.uk
  13.  
  14. In article <4igck9$idj@masala.cc.uh.edu> BSamuel@uh.edu "Binoy K. Samuel" writes:
  15.  
  16. >Hi:
  17. >
  18. >I am taking a C class this semester.
  19. >
  20. >And I have just written a program that runs (more or less) quite well.
  21. >
  22. >However, when I try to compile it, I get the following error:
  23. >        
  24. >        "Call to function 'evalchar' with no prototype"
  25. >
  26. >Why does this happen? 'Evalchar' is a function that I wrote.  What 
  27. >prototype should I be looking for.
  28. >
  29. >Here's the function header line:
  30. >
  31. >        char evalchar(cnum)
  32. >        int cnum;
  33.  
  34. This isn't a prototype. A prototype is a form of function declaration
  35. introduced with ANSI C that states type information in the parameter list,
  36. i.e. between the ()'s. The compiler can perform suitable argument type
  37. checking and conversion when a prototype is in scope. While prototypes aren't
  38. mandatory (the compiler should have just warned, not refused to generate
  39. an executable) the compiler is giving you good advice that you should use
  40. them. Prototyped forms look like:
  41.  
  42.     char evalchar(int cnum);
  43.  
  44. for a declaration and
  45.  
  46.     char evalchar(int cnum)
  47.     {
  48.        /* ... */
  49.     }
  50.  
  51. for a function definition (i.e. where you rovide the function body).
  52.  
  53. >I'm using Borland C++'s C compiler.
  54.  
  55. If you wanted to compile a C program rather than C++ make sure you used the
  56. right compiler options.
  57.  
  58. >Please e-mail me if you can. This is the first time I'm writing to this 
  59. >newsgroup: I don't usually look here that often.
  60.  
  61. However you've now posted a question so you have a very good reason to look
  62. more often (at least at this particular thread). comp.lang.c isn't a
  63. write-only newsgroup. If you post a question be prepared to read the answers
  64. here so that others can also see them and comment on them.
  65.  
  66. -- 
  67. -----------------------------------------
  68. Lawrence Kirby | fred@genesis.demon.co.uk
  69. Wilts, England | 70734.126@compuserve.com
  70. -----------------------------------------
  71.